<template>
  <div class="layout h-full relative" ref="layoutRef">
    <div class="top" ref="topRef">
      <slot></slot>
    </div>

    <div class="bottom fixed bottom-0 w-full" ref="bottomRef">
      <slot name="bottom"></slot>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  name: "BottomFixed",
  components: {},
  props: {
    fixedTopHeight: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {};
  },
  computed: {},
  watch: {},
  beforeCreate() {},
  created() {},
  beforeMount() {},
  mounted() {
    const bottomHeight = this.$refs.bottomRef.clientHeight;
    this.$refs.topRef.style.marginBottom = `${bottomHeight}px`;

    if (this.fixedTopHeight) {
      const layoutHeight = this.$refs.layoutRef.clientHeight;
      this.$refs.topRef.style.height = `${layoutHeight - bottomHeight}px`;
    }
  },
  beforeUpdate() {},
  updated() {},
  methods: {},
  beforeUnmount() {},
  unmounted() {},
});
</script>

<style scoped lang="scss"></style>
